package com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.ui.personalcenter;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.activity.ActivityLogin;
import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.activity.ActivityMedicineFeedback;
import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.databinding.FragmentPersonalCenterBinding;
import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.model.UserViewModel;
import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.utils.GlobalViewModelStore;
import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.utils.MyApplication;

public class PersonalCenterFragment extends Fragment {

    private FragmentPersonalCenterBinding binding;
    private PersonalCenterViewModel mViewModel;
    private UserViewModel userViewModel;


    public static PersonalCenterFragment newInstance() {
        return new PersonalCenterFragment();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        binding = FragmentPersonalCenterBinding.inflate(inflater, container, false);
        View view = binding.getRoot();

        setUserViewModel();

        setLayouts();

        return view;
    }

    private void setLayouts(){
        binding.idVerificationLayout.setOnClickListener(v->{

        });
        binding.medicationFeedbackLayout.setOnClickListener(v->{
            Intent intent = new Intent(requireContext(), ActivityMedicineFeedback.class);
            startActivity(intent);
        });
        binding.myFavoritesLayout.setOnClickListener(v->{

        });
        binding.accountInfoLayout.setOnClickListener(v->{

        });
        binding.exitLoginLayout.setOnClickListener(v->{
            //退出登录
            Intent intent = new Intent(requireContext(), ActivityLogin.class);
            startActivity(intent);
        });
    }

    private void setUserViewModel(){
        //用户身份
        // 获取全局共享的 UserViewModel
        userViewModel = GlobalViewModelStore
                .getInstance(MyApplication.getInstance())
                .get(UserViewModel.class);
    }

}